ci: skip image push in forked repositories#2805
Conversation
|
|
||
| build-and-push-image: | ||
| if: github.event_name != 'pull_request' | ||
| if: github.event_name != 'pull_request' && github.repository == 'docker/docker-agent' |
There was a problem hiding this comment.
Non-blocking (consider): Hardcoding the repo slug docker/docker-agent works, but couples this guard to the repository name — a future rename or transfer would silently disable image pushes from main/tags.
A more intent-revealing alternative is to gate on whether the workflow is running in a fork:
if: github.event_name != 'pull_request' && !github.event.repository.forkgithub.event.repository.fork is false for the upstream and true for any fork, which is exactly the property we care about ("don't try to push from forks"). It's also rename/transfer-proof and matches the language of the PR title ("skip image push in forked repositories").
Either approach is fine — happy to merge as-is if you prefer the explicit allow-list form, but worth a thought.
There was a problem hiding this comment.
Hm. didn’t know github events had a property like that. your suggestion is much cleaner 👍🏻
got notification about failing build job in my forked repo
this should be skipped while other jobs run as normal